package com.pc.mapper;

import com.pc.pojo.UserAccount;
import org.apache.ibatis.annotations.*;

@Mapper
public interface UserAccountMapper {

    @Select("SELECT * FROM user_account WHERE username = #{username}")
    UserAccount selectByUsername(String username);

    @Select("SELECT * FROM user_account WHERE user_id = #{userId}")
    UserAccount selectByUserId(Long userId);

    @Delete("delete from user_account where user_id = #{userId}")
    void delete(long userId);

    @Insert("INSERT INTO user_account (username, password, phone, status,type) " +
            "VALUES (#{username}, #{password}, #{phone}, #{status},#{type})")
    @Options(useGeneratedKeys = true, keyProperty = "userId", keyColumn = "user_id")
    void register(UserAccount userAccount);

    @Insert("insert into user_role_rel(user_id, role_id) value (#{userId},#{i})")
    void insertUserRole(Long userId, int i);
}
